/**
 * 应用中心-应用管理mock拦截,
 * 方法集
 * create by xyr on 2017-11-15
 */

import Mock from 'mockjs';

export default {
    createAppByFileContent: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: {
                statusCode: 200,
                message: '成功创建应用'
            }
        }
    },
    createAppByUploadFile: () => {
        
        return {
            meta: {
                code: 200,
                message: '成功创建应用'
            },
            data: {
                statusCode: 200,
                message: '成功创建应用'
            }
        }
    },
    queryApps: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: {
                total: 1,
                items: [
                    {
                        id: '1234567890',
                        appName: '测试Tomcat-555',
                        imageName: 'Tomcat',
                        imageVersion: '1.0',
                        replicas: '1/2',
                        status: '创建中...',
                        timeDiff: '3天',
                        createTime: '2016-11-09 12:32:32',
                        lastUpdateTime: '2017-11-11 11:11:11',
                        described: '我是测试应用',
                        statusMessage: '',
                        appKind: 'Deployment'
                    },
                ]

            }
        }
    },
    getAppBase: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: {
                id: '1234567890',
                appName: '测试Tomcat-555',
                namespace: 'nipdev',
                appNameKube: 'tomcat-6',
                imageName: 'Tomcat',
                imageVersion: '1.0',
                replicas: '1/1',
                status: '运行中',
                timeDiff: '3天',
                createTime: '2016-11-09 12:32:32',
                lastUpdateTime: '2017-11-11 11:11:11',
                described: '我是测试应用',
                statusMessage: '容器正常运行',
                appKind: 'Deployment',
                autoScale: true
            }
        }
    },
    getPodList: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: [
                {
                    id: '',
                    appName: 'Tomcat-66666',
                    appNameKube: 'Tomcat-66666',
                    imageName: 'Tomcat',
                    imageVersion: '1.0',
                    replicas: '',
                    status: 'Running',
                    timeDiff: '3天',
                    createTime: '2016-11-09 12:32:32',
                    lastUpdateTime: '2017-11-11 11:11:11',
                    described: '我是测试应用',
                    statusMessage: '容器正常运行',
                    restartCount: 8
                }
            ]
        }
    },
    horizontalScalingApp: () => {
        return {
            meta: {
                code: 200,
                message: '水平伸缩应用,成功'
            },
            data: {}
        }
    },
    getAppHpa: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: {
                minReplicas: 1,
                maxReplicas: 8,
                targetCpuPercent: 50,
                appNameKube: 'Tomcat12345',
                namespace: 'nipdev'
            }
        }
    },
    autoScaleApp: () => {
        return {
            meta: {
                code: 200,
                message: '自动伸缩成功'
            },
            data: {
            }
        }
    },
    deleteApp: () => {
        return {
            meta: {
                code: 200,
                message: '删除应用成功'
            },
            data: {
            }
        }
    },
    getAppName: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: 704
        }
    },
    // 获得镜像列表
    getProjectImages: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: [
                {
                    name: 'tomcat1',
                    creation_time: '2017-11-22 12:12:21'
                },
                {
                    name: 'tomcat2',
                    creation_time: '2017-11-22 12:12:21'
                },
                {
                    name: 'tomcat2',
                    creation_time: '2017-11-22 12:12:21'
                }
            ]
        }
    },
    // 根据镜像名称,获取镜像信息
    getImageBase: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: {
                imageBase: {
                    id: '1234578988',
                    appName: 'Tomcat-test', // 应用名称
                    appNameKube: "tomcat-test", // 应用名称(k8s)
                    image: "Tomcat-test", // 镜像
                    imageVersion: "2.0", // 镜像版本
                    described: "Tomcat-test", // 描述
                    appKind: "Deployment", // 部署方式: 无状态,有状态
                    replicas: 2, // 部署实例个数
                    requestsMemory: "126Mi", // 应用请求内存
                    limitsMemory: "512Mi", // 应用最大使用的内存
                    startCommand: 1, // 启动命令类型
                    command: "", // 命令
                    imagePullPolicy: "Always" // 拉取镜像的方式
                },
                portDataList: [
                    {
                        id: '1',
                        port: 22,
                        protocol: "HTTP",
                        visible: true,
                        portType: "dynamic",
                        nodePort: 8080,
                        domainName: '',
                        domainNameTyep: 'dynamic'
                    },
                    {
                        id: '2',
                        port: 8080,
                        protocol: "TCP",
                        visible: false,
                        portType: "appoint",
                        nodePort: 8888,
                        domainName: '',
                        domainNameTyep: 'dynamic'
                    }
                ],
                envDataList: [
                    {
                        id: '1',
                        envKey: "add",
                        envValue: "22222222" 
                    },
                    {
                        id: '2',
                        envKey: "asd",
                        envValue: "2345" 
                    },
                ],
                configVolumesDataList: [
                    {   
                        id: '1',
                        mouthPath: "/mnt/data",
                        configGroup: "Tomcat-1",
                        configFiles: ['a.txt'],
                        configFilesArr: []
                    },
                    {
                        id: '2',
                        mouthPath: "/mnt/data/ASD",
                        configGroup: "Tomcat-2",
                        configFiles: ['b.txt'],
                        configFilesArr: []
                    }
                ],
                imageHA: {
                    id: '1',
                    image: "tomcat-test",
                    type: 2,
                    port: 22,
                    initialDelaySeconds: 60,
                    periodSeconds: 120,
                    timeoutSeconds: 30,
                    path: '/mnt/hahahahaha'
                }

            }
        }
    },
    // 得到镜像版本列表
    getImageTag: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: [
                {
                    name: '1.0',
                    creation_time: '2017-11-22 12:12:21'
                },
                {
                    name: '2.0',
                    creation_time: '2017-11-22 12:12:21'
                },
                {
                    name: '3.0',
                    creation_time: '2017-11-22 12:12:21'
                }
            ]
        }
    },
    // 
    depyoyApp: () => {
        return {
            meta: {
                code: 200,
                message: ''
            },
            data: []
        }
    }
}